OlePut Question

I'm working on some integration between tools and have run into a snag that is causing me to loose precious remaining hair :

In VB I'd do the following

     oReq.Name = "ReqName"                                and in DOORS it would be :    olePut( oReq, "Name" , "ReqName")

But for

   oReq.Field("RQ_USER_TEMPLATE_02") = "value"       I've tried multiple ways of doing this and cannot seem to get it working

Any suggestions ?
 

 

I've tried multiple ways to do this via DXL


Chris_Welch - Fri May 16 13:24:23 EDT 2014

Re: OlePut Question
llandale - Sun May 18 16:17:35 EDT 2014

Don't have the VBA reference in front of me so the following is suspect.

olePut and oleGet refer to Properties of an Object.  oleMethod of course referes to methods of an Object.

I'm thinking that "Field" thing is an Object, which you can get as an oleMethod of the oReq.  I'm guessing that then you olePut THAT object a value.

-Louie

Re: OlePut Question
Mathias Mamsch - Mon May 19 04:00:05 EDT 2014

As far as I know the VBA syntax you are using is a short form of the full syntax (using a default property):

oReq.Field(...).<default property> = value ...

So in your case you would probably look at the reference for the function you are calling, find out the name of the default property and then do:

oleMethod(oReq, Field, ..., objResult)

olePut(objResult, <default name>, value)

Maybe this helps, regards, Mathias

Re: OlePut Question
Chris_Welch - Mon May 19 10:31:48 EDT 2014

Mathias Mamsch - Mon May 19 04:00:05 EDT 2014

As far as I know the VBA syntax you are using is a short form of the full syntax (using a default property):

oReq.Field(...).<default property> = value ...

So in your case you would probably look at the reference for the function you are calling, find out the name of the default property and then do:

oleMethod(oReq, Field, ..., objResult)

olePut(objResult, <default name>, value)

Maybe this helps, regards, Mathias

Field("XXXXXXX") is the only way to access add-on fields (customized schema) within the tool

There is a "Fields" method at the oReqFactory level but only a Field method on the Requirement.

I need somehow to reference the field property, name and value but olePut doesn't seem to accept any combination of things I've tried.

Re: OlePut Question
Mathias Mamsch - Mon May 19 15:03:22 EDT 2014

Chris_Welch - Mon May 19 10:31:48 EDT 2014

Field("XXXXXXX") is the only way to access add-on fields (customized schema) within the tool

There is a "Fields" method at the oReqFactory level but only a Field method on the Requirement.

I need somehow to reference the field property, name and value but olePut doesn't seem to accept any combination of things I've tried.

Open Excel, then go to VBA and execute:

Application.ActiveSheet.Cells.Item(2, 4).Value = 7
Application.ActiveSheet.Cells.Item(2, 3) = 6
Application.ActiveSheet.Cells(2, 2) = 5
ActiveSheet.Cells(3, 3) = 4
Cells(2, 1).Value = 3
Cells(1, 1) = 2


You will see that all statements execute. In fact all those statements do exactly the same. Why? Because VBA knows 'Default' properties ... You can leave out Application, because all statements will be executed on Application if nothing is explicitly mentioned. You can leave out 'Activesheet' because Application has a direct 'Cells' property that will call Activesheet.Cells internally.

Now why can you leave out 'Items' ? Because Cells actually returns a Range objects which has Item as a default property. And I guess for exactly the same reason you can leave out the ".Value"... Read more about it for example here:

https://colinlegg.wordpress.com/2012/01/24/making-sense-of-cells-intellisense-part-1/

My guess is, that it is the same is true for your library. Make sure that you show 'hidden' properties and examine your library in the object explorer. I was successful in DXL by executing the following code:

OleAutoArgs args = create()

OleAutoObj appExcel = oleGetAutoObject "Excel.Application"
OleAutoObj objRange, objDefault = null

// get a Range object
clear args
put(args, 1)
put(args, 2)
oleGet(appExcel, "Cells",args, objRange)

// access the default property of the Range object ...
clear args
put(args, 5)
put(args, 5)
oleGet(objRange, "_Default", args, objDefault)

print (null objDefault)
olePut(objDefault, "Value", 101)


So it seems, DXL lets us access the default property. Maybe this will help in your case too. Regards, Mathias

Re: OlePut Question
Chris_Welch - Tue May 20 10:58:31 EDT 2014

Mathias Mamsch - Mon May 19 15:03:22 EDT 2014

Open Excel, then go to VBA and execute:

Application.ActiveSheet.Cells.Item(2, 4).Value = 7
Application.ActiveSheet.Cells.Item(2, 3) = 6
Application.ActiveSheet.Cells(2, 2) = 5
ActiveSheet.Cells(3, 3) = 4
Cells(2, 1).Value = 3
Cells(1, 1) = 2


You will see that all statements execute. In fact all those statements do exactly the same. Why? Because VBA knows 'Default' properties ... You can leave out Application, because all statements will be executed on Application if nothing is explicitly mentioned. You can leave out 'Activesheet' because Application has a direct 'Cells' property that will call Activesheet.Cells internally.

Now why can you leave out 'Items' ? Because Cells actually returns a Range objects which has Item as a default property. And I guess for exactly the same reason you can leave out the ".Value"... Read more about it for example here:

https://colinlegg.wordpress.com/2012/01/24/making-sense-of-cells-intellisense-part-1/

My guess is, that it is the same is true for your library. Make sure that you show 'hidden' properties and examine your library in the object explorer. I was successful in DXL by executing the following code:

OleAutoArgs args = create()

OleAutoObj appExcel = oleGetAutoObject "Excel.Application"
OleAutoObj objRange, objDefault = null

// get a Range object
clear args
put(args, 1)
put(args, 2)
oleGet(appExcel, "Cells",args, objRange)

// access the default property of the Range object ...
clear args
put(args, 5)
put(args, 5)
oleGet(objRange, "_Default", args, objDefault)

print (null objDefault)
olePut(objDefault, "Value", 101)


So it seems, DXL lets us access the default property. Maybe this will help in your case too. Regards, Mathias

Mathias

I tried the method you suggested but the API doesn't seem to support it.   I'm still working with IBM support (not holding my breath for them to provide a solution) but I've found a workaroudn that seems to give me a means to do what I need by using a SQL update.

   clear( objArg )
   olePut( oCmd , "CommandText", "Update REQ set RQ_USER_TEMPLATE_02 = '" sMUID "' Where RQ_REQ_ID = " iChild ""  )  
   oleMethod( oCmd , "Execute" )   "\n"
 

I would still prefer to do a direct update on the values before posting/committing the changes but at least this works (for now).
Thanks again!

Re: OlePut Question
Mathias Mamsch - Tue May 20 13:08:09 EDT 2014

Chris_Welch - Tue May 20 10:58:31 EDT 2014

Mathias

I tried the method you suggested but the API doesn't seem to support it.   I'm still working with IBM support (not holding my breath for them to provide a solution) but I've found a workaroudn that seems to give me a means to do what I need by using a SQL update.

   clear( objArg )
   olePut( oCmd , "CommandText", "Update REQ set RQ_USER_TEMPLATE_02 = '" sMUID "' Where RQ_REQ_ID = " iChild ""  )  
   oleMethod( oCmd , "Execute" )   "\n"
 

I would still prefer to do a direct update on the values before posting/committing the changes but at least this works (for now).
Thanks again!

Good that you found a workaround ... I am still convinced this must be possible. Are you trying to access a database using ADO here, tryint to set a field in a recordset? Regards, Mathias

Re: OlePut Question
Chris_Welch - Tue May 20 13:13:37 EDT 2014

Mathias Mamsch - Tue May 20 13:08:09 EDT 2014

Good that you found a workaround ... I am still convinced this must be possible. Are you trying to access a database using ADO here, tryint to set a field in a recordset? Regards, Mathias

Actually we are using the QualityCenter (TDAPI) to move data between DOORS & ALM/QC.    I've already written the ALM to DOORS piece and am working on the DOORS to ALM component.    At some point I'll be pulling ALM/QC defects into DOORS to track defects against requirements as well :)